package com.jdk.demo.thread.threadpool;

import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

public class PoolDemo4 {

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		ExecutorService pool = Executors.newFixedThreadPool(2);
	    Random random = new Random();

	    Future<String> f = pool.submit(new Callable<String>() {

			@Override
			public String call() throws Exception {
				Thread.sleep(500);
				return "zsl";
			}

	    });
	    Thread.sleep(1000);
	    pool.shutdown();
	    pool.awaitTermination(1000, TimeUnit.MICROSECONDS);
	}

}
